<template>
<!--    我参加的活动-->
    <div>
        <el-card class="box-card" v-for="(item, index) in list" :key="index" style="margin-bottom: 30px">
            <div v-for="(a,b) in item.activity" :key="b">
                <div style="display: flex;justify-content: space-between;align-items: center">
                    <h4>{{a.title}}</h4>
                    <div v-if="item.audit == 0" style="color: orange">报名状态：{{item.audit | audit}}</div>
                    <div v-if="item.audit == 1" style="color: #409eff">报名状态：{{item.audit | audit}}</div>
                    <div v-if="item.audit == 2" style="color: #f56c6c">报名状态：{{item.audit | audit}}</div>
                </div>

                <div style="margin-top: 10px">{{a.content}}</div>
                <div style="display: flex;justify-content: space-between;align-items: center">
                    <div style="font-size: 13px">
                        <div style="margin-top: 10px">类型：{{a.type}}</div>
                    </div>
                    <div style="font-size: 13px">
                        <div style="margin-top: 10px">活动结束时间：{{a.end_time}}</div>
                    </div>
                </div>
                <div style="display: flex;justify-content: space-between;align-items: center">
                    <div style="font-size: 12px;margin-top: 10px">专业：{{a.professional}}</div>
                    <div style="font-size: 12px;margin-top: 10px">参加人：{{item.name}}</div>
                </div>
            </div>
        </el-card>
        <div style="text-align: center;margin-top: 20px;cursor: pointer" @click="more" v-show="ismore">加载更多</div>
    </div>
</template>

<script>
    import {getuseractivity,getactivity} from '../api/api'
    export default {
        filters: {
            audit(value){
                if (value == 0){
                    return '审核中'
                }else if(value == 1){
                    return '审核通过'
                }else {
                    return '拒绝'
                }
            }
        },
        name: "myActivity",
        data(){
            return{
                list:[],
                n:1,
                ismore:true
            }
        },
        methods:{
            get(n){
                getuseractivity(n).then(res=>{
                    if(res.status == 0){
                        if(res.data.length == 0){
                            this.ismore = false
                        }
                        // console.log(res)
                        var list1 = res.data
                        res.data.forEach(value=>{
                            value.activity = []
                            getactivity(value.activity_id).then(a=>{
                                // console.log(a)
                                if(a.status == 0){
                                    value.activity = a.data
                                }
                            })
                        })
                        // console.log(list1)
                        this.list = this.list.concat(list1)
                    }
                })
            },
            more(){
                this.n++
                this.get(this.n)
            }
        },
        created() {
            this.get(this.n)
        }
    }
</script>

<style scoped>

</style>
